﻿namespace Alkitab
{
    using System;
    using System.ComponentModel;

    public class AyatMazmur : INotifyPropertyChanged
    {
        #region Fields

        private String[,] x = new String[8, 4];

        #endregion Fields

        #region Constructors

        public AyatMazmur(String input)
        {
            bool adaInden = false;
            int lineNo = 1;
            int[] foundAt = new int[2];
            bool found = false;
            string prefix = "";
            for (int i = 0; i < input.Length; i++)
            {
                if (input[i].Equals('@') || i == input.Length - 1)
                {
                    if (prefix.Equals("")) prefix = input.Substring(0, i);
                    adaInden = true;
                    if (found)
                    {
                        if (lineNo == 1)
                        {
                            x[lineNo, foundAt[0]] = prefix + input.Substring(foundAt[1], i - foundAt[1]);
                        }
                        else
                        {
                            x[lineNo, foundAt[0]] = input.Substring(foundAt[1], i - foundAt[1]);
                        }
                        lineNo++;
                        found = false;
                    }
                }
                else
                {
                    if (adaInden)
                    {
                        if (input[i].Equals('0'))
                        {
                            foundAt[0] = 1;
                            foundAt[1] = i + 1;
                            found = true;
                        }
                        if (input[i].Equals('1'))
                        {
                            foundAt[0] = 2;
                            foundAt[1] = i + 1;
                            found = true;
                        }
                        if (input[i].Equals('2'))
                        {
                            foundAt[0] = 3;
                            foundAt[1] = i + 1;
                            found = true;
                        }
                        if (input[i].Equals('8'))
                        {
                            x[lineNo, 1] = "\n";
                            lineNo++;
                            adaInden = false;
                        }
                    }
                }
            }
        }

        #endregion Constructors

        #region Events

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion Events

        #region Properties

        public String x11
        {
            get
            {
                return x[1, 1];
            }
            set
            {
                if (value != this.x[1, 1])
                {
                    this.x[1, 1] = value;
                    NotifyPropertyChanged("x11");
                }
            }
        }

        public String x12
        {
            get
            {
                return x[1, 2];
            }
            set
            {
                if (value != this.x[1, 2])
                {
                    this.x[1, 2] = value;
                    NotifyPropertyChanged("x12");
                }
            }
        }

        public String x13
        {
            get
            {
                return x[1, 3];
            }
            set
            {
                if (value != this.x[1, 3])
                {
                    this.x[1, 3] = value;
                    NotifyPropertyChanged("x13");
                }
            }
        }

        public String x21
        {
            get
            {
                return x[2, 1];
            }
            set
            {
                if (value != this.x[2, 1])
                {
                    this.x[2, 1] = value;
                    NotifyPropertyChanged("x21");
                }
            }
        }

        public String x22
        {
            get
            {
                return x[2, 2];
            }
            set
            {
                if (value != this.x[2, 2])
                {
                    this.x[2, 2] = value;
                    NotifyPropertyChanged("x22");
                }
            }
        }

        public String x23
        {
            get
            {
                return x[2, 3];
            }
            set
            {
                if (value != this.x[2, 3])
                {
                    this.x[2, 3] = value;
                    NotifyPropertyChanged("x23");
                }
            }
        }

        public String x31
        {
            get
            {
                return x[3, 1];
            }
            set
            {
                if (value != this.x[3, 1])
                {
                    this.x[3, 1] = value;
                    NotifyPropertyChanged("x31");
                }
            }
        }

        public String x32
        {
            get
            {
                return x[3, 2];
            }
            set
            {
                if (value != this.x[3, 2])
                {
                    this.x[3, 2] = value;
                    NotifyPropertyChanged("x32");
                }
            }
        }

        public String x33
        {
            get
            {
                return x[3, 3];
            }
            set
            {
                if (value != this.x[3, 3])
                {
                    this.x[3, 3] = value;
                    NotifyPropertyChanged("x33");
                }
            }
        }

        public String x41
        {
            get
            {
                return x[4, 1];
            }
            set
            {
                if (value != this.x[4, 1])
                {
                    this.x[4, 1] = value;
                    NotifyPropertyChanged("x41");
                }
            }
        }

        public String x42
        {
            get
            {
                return x[4, 2];
            }
            set
            {
                if (value != this.x[4, 2])
                {
                    this.x[4, 2] = value;
                    NotifyPropertyChanged("x42");
                }
            }
        }

        public String x43
        {
            get
            {
                return x[4, 3];
            }
            set
            {
                if (value != this.x[4, 3])
                {
                    this.x[4, 3] = value;
                    NotifyPropertyChanged("x43");
                }
            }
        }

        public String x51
        {
            get
            {
                return x[5, 1];
            }
            set
            {
                if (value != this.x[5, 1])
                {
                    this.x[5, 1] = value;
                    NotifyPropertyChanged("x51");
                }
            }
        }

        public String x52
        {
            get
            {
                return x[5, 2];
            }
            set
            {
                if (value != this.x[5, 2])
                {
                    this.x[5, 2] = value;
                    NotifyPropertyChanged("x52");
                }
            }
        }

        public String x53
        {
            get
            {
                return x[5, 3];
            }
            set
            {
                if (value != this.x[5, 3])
                {
                    this.x[5, 3] = value;
                    NotifyPropertyChanged("x53");
                }
            }
        }

        public String x61
        {
            get
            {
                return x[6, 1];
            }
            set
            {
                if (value != this.x[6, 1])
                {
                    this.x[6, 1] = value;
                    NotifyPropertyChanged("x61");
                }
            }
        }

        public String x62
        {
            get
            {
                return x[6, 2];
            }
            set
            {
                if (value != this.x[6, 2])
                {
                    this.x[1, 1] = value;
                    NotifyPropertyChanged("x62");
                }
            }
        }

        public String x63
        {
            get
            {
                return x[6, 3];
            }
            set
            {
                if (value != this.x[6, 3])
                {
                    this.x[1, 1] = value;
                    NotifyPropertyChanged("x63");
                }
            }
        }

        public String x7
        {
            get
            {
                return x[7, 1];
            }
            set
            {
                if (value != this.x[7, 1])
                {
                    this.x[7, 1] = value;
                    NotifyPropertyChanged("x7");
                }
            }
        }

        #endregion Properties

        #region Methods

        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        #endregion Methods
    }
}